
<!-- 项目考核--在线相册

需求：
可以发布相册，显示相册，编辑相册以及删除相册。
相册需带标题，内容以及发布时间

要求：
样式需引入bootstrap，简约大方。
功能完善，验收的时候，不能有报错，不能有打印。 -->




<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>在线相册</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    </head>
    <body>
      <!-- 导航条-->
		<nav class="navbar navbar-inverse">
		  <div class="container-fluid">
		  <div class="navbar-header">
		      <a class="navbar-brand" href="#">
		        <img alt="在线相册" src="...">
		      </a>
		  </div>
		  </div>
		</nav>
         <!-- 巨幕-->
		<div class="jumbotron">
        <h1>记录生活点滴美好</h1>
        <p>偶尔翻翻以前的东西,总会涌上思绪万千,而且还会留在脑海中不断翻腾,经久不散。同样的,我无意中翻出了小时候的画册,又有许多浮现在眼前。小时候每个人...</p>
        <p><a class="btn btn-primary btn-lg" href="./addphoto.html" role="button">添加相册</a></p>
       </div>

      <!-- 缩省图内容-->
       
<!-- <div class="container" id="del">	 -->

<?php 
 
// var_dump($_POST);
//第一步连接数据库服务器；
@mysql_connect('localhost','root','root');
//第二步判断是否正确连接；
if (mysql_errno()) {
  die(mysql_error());
}
//第三步选择数据库
 mysql_select_db('photo');
//第四步设置字符集
 mysql_set_charset('utf8');
//第五步写入SQL语句
  $sql ="select * from photo";
 
  //第六步 发送SQL语句到MYSQL服务器
  $res = mysql_query($sql);
  //第七部处理结果集
  $result =[];
  while ( $row =mysql_fetch_assoc($res)) {
   $result[] =$row;
    
     echo '<div class="col-sm-6 col-md-4">';
     echo '<div class="thumbnail">';
     echo '<img src=' . $row['src'] . ' style="width:230px; height:230px;">';
     echo '<div class="caption">';
     echo '<h3>'.$row['title'].'</h3>';
     echo '<p>'.substr($row['content'], '0','50').'...</p>';
     echo  '<p>'.$row['time'].'</p>';
     echo'<p><a href=' . "update.php" . '?id=' . $row['id'] . ' class="btn btn-default" role="button">编辑</a> <a href=' . "del.php" . '?id=' . $row['id'] . ' class="btn btn-default" role="button">删除</a></p>';
        echo'</div>';
        echo'</div>';
        echo'</div>';
      
  

  }

 // var_dump($result);

 //第八步释放结果集资源，关闭数据库连接
 // mysql_free_result($res);//如果是dml语句这一句不要
 // mysql_close();
  
 ?>

       
      <!--   <div class="col-sm-6 col-md-4">
        <div class="thumbnail">
        <img src="<?php echo $result['0']['src'];?>" alt="..." >
        <div class="caption">
        <h3><?php echo $result['0']['title'];?></h3>
        <p><?php echo $result['0']['content'];?></p>
        <p><?php echo $result['0']['time'];?></p>
        <p><a href="update.php" class="btn btn-primary" role="button">编辑</a> <a href='del.php?' class="btn btn-default" role="button">删除</a></p>
        </div>
        </div>
        </div>
     




       
       <div class="col-sm-6 col-md-4">
        <div class="thumbnail">
        <img src="<?php echo $result['1']['src'];?>" alt="..." >
        <div class="caption">
        <h3><?php echo $result['1']['title'];?></h3>
        <p><?php echo $result['1']['content'];?></p>
        <p><?php echo $result['1']['time'];?></p>
        <p><a href="update.php" class="btn btn-primary" role="button">编辑</a> <a href='del.php?' class="btn btn-default" role="button">删除</a></p>
        </div>
        </div>
        </div>
      




       
     <div class="col-sm-6 col-md-4">
        <div class="thumbnail">
        <img src="<?php echo $result['2']['src'];?>" alt="...">
        <div class="caption">
        <h3><?php echo $result['2']['title'];?></h3>
        <p><?php echo $result['2']['content'];?></p>
        <p><?php echo $result['2']['time'];?></p>
        <p><a href="update.php" class="btn btn-primary" role="button">编辑</a> <a href='del.php' class="btn btn-default" role="button">删除</a></p>
        </div>
        </div>
        </div>


    <div class="col-sm-6 col-md-4">
        <div class="thumbnail">
        <img src="<?php echo $result['2']['src'];?>" alt="...">
        <div class="caption">
        <h3><?php echo $result['2']['title'];?></h3>
        <p><?php echo $result['2']['content'];?></p>
        <p><?php echo $result['2']['time'];?></p>
        <p><a href="update.php" class="btn btn-primary" role="button">编辑</a> <a href='del.php' class="btn btn-default" role="button">删除</a></p>
        </div>
        </div>
        </div>
      -->
<!-- </div> -->
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>

